/******************************************************************************
 * SAGE - Scalable Adaptive Graphics Environment
 *
 * Module: tileConfig.h
 * Author : Byungil Jeong
 *
 * Copyright (C) 2004 Electronic Visualization Laboratory,
 * University of Illinois at Chicago
 *
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either Version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
 * License for more details.
 *
 * You should have received a copy of the GNU Lesser Public License along
 * with this library; if not, write to the Free Software Foundation, Inc.,
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *
 * Direct questions, comments etc about SAGE to bijeong@evl.uic.edu or 
 * http://www.evl.uic.edu/cavern/forum/
 *
 *****************************************************************************/

#ifndef SAGE_TILE_CONFIG_H
#define SAGE_TILE_CONFIG_H

#include "sageBase.h"

// width : horizontal screen resolution
// height : vertical screen resolution
// left : left mullion width
// right : left mullion width
// bottom : left mullion width
// top : left mullion width
class displayType : public sageRect {
public:
	char name[SAGE_NAME_LEN];
	int PPI; //pixel per inch

	displayType() : PPI(0) {}
};

// x, y : lower left corner coordinates in pixels
// width, height : screen resolution
// left, right, bottom, top : relative coordinates (0.0 - 1.0)
class tileInfo : public sageRect {
public:
	displayType *tileType;
	int nodeID, tileID;
	int xIndex, yIndex;
	int offsetX, offsetY;
	
	tileInfo() : tileType(NULL), nodeID(0), tileID(0), offsetX(0), offsetY(0),
			 xIndex(0), yIndex(0) {}
};

class displayNode {
public:
	char ip[SAGE_IP_LEN];		//ip address of the computer the holds pixels to display
	std::vector<char*> streamIPs; // optional parameters to receive streams through separate IPs
	std::vector<tileInfo*> tiles;   // tile ID attached to this display node
	int dimX, dimY;
		
	displayNode();
	~displayNode();
	int computeDimension();
};

class audioNode {
public:
        char ip[SAGE_IP_LEN];                           //ip address of the computer the holds pixels to display
        std::vector<char*> streamIPs;           // optional parameters to receive streams through separate IPs

        // ?????????????
        //int  audioDeviceNum;
        sageSampleFmt sampleFmt;
        long samplingRate;
        int  channels;
        int  framePerBuffer;
        int  deviceId;

        audioNode();
        ~audioNode();
};


// x, y : lower left corner coordinates in pixels on global desktop
// width, height : virtual desktop resolution
class virtualDesktop : public sageRect {
public:	
	std::vector<tileInfo*> tileList;	
	std::vector<displayNode*> displayCluster;
	std::vector<audioNode*> audioCluster;

	int dimX, dimY;
	displayType globalType;
	
	virtualDesktop();
	int parseConfigfile(FILE *fp, bool configBegin = false);
	int parseAudioConfigfile(FILE *fp, bool configBegin = false);
	int updateDesktop();
};

#endif
